/**
 * 
 */
package edu.vanderbilt.vshare.multicast;

import java.util.Comparator;

/**
 * specialized comparator class for weighted work units
 * 
 * @author jedmondson
 *
 */
public class WeightedWorkUnitComparator implements Comparator<WeightedWorkUnit> {

	/**
	 * compare the weight of two WeightedWorkUnits
	 * 
	 * @param     arg0               left hand side value
	 * @param     arg1               right hand side value
	 * @return                       -1 if arg0.weight < arg1.weight
	 *                               0 if arg0.weight == arg1.weight
	 *                               1 if arg0.weight > arg1.weight
	 */
	@Override
	public int compare(WeightedWorkUnit arg0, WeightedWorkUnit arg1) {
		// if weight is less, return -1
		if( arg0.getWeight() < arg1.getWeight() )
			return -1;
		// if weight is equal return 0
		if( arg0.getWeight() == arg1.getWeight() )
			return 0;
		// otherwise, arg0.weight > arg1.weight
		return 1;
	}

}
